#ifndef VIDEO_H 
#define VIDEO_H

extern "C"
{
#include <avcodec.h>
#include <avformat.h>
#include <swscale.h> 
}

#include <stdio.h>
#include "Timestamp.h"
#include <vector>


class video
{
	public:
		video() { };
		video(char* filename);
		AVFrame* DecodeVideo( AVPacket packet );
		void DecodeAudio( AVPacket packet );
		int16_t* GetSample() { return sample; };
		int GetBuffersize() { return buffersize; };
		void Close();
		AVFormatContext* GetAVFormatContext();
		AVCodecContext* GetVideoCodecContext();
		AVCodecContext* GetAudioCodecContext();
		int GetVideoStreamIndex() { return video_stream_id; };
		int GetAudioStreamIndex() { return audio_stream_id; };
		int GetWidth() { return width; };
		int GetHeight() { return height; };
		Timestamp* GetPart();
		void SetPart(int begin, int end);
		bool IsPartSet();
		bool IsSample() { return gotsample; };

		

	private:

		 AVFormatContext *format_context;
		 int video_stream_id;
		 int audio_stream_id;
		 AVCodecContext *video_codec_context;
		 AVCodecContext *audio_codec_context;
		 int width;
		 int height;
		 AVCodec *video_codec;
		 AVCodec *audio_codec;
		 AVFrame *frame;
		 Timestamp *part;
		 bool PartSet;
		 FILE *faudio;
		 int16_t* sample;
		 int buffersize;
		 bool gotsample;
		 int totalAudio;


};

#endif